#include "ThreadPool.h"
#include <iostream>
#include <chrono>
#include <string>

using namespace std::literals::chrono_literals;

std::string test_func(int x) {
    std::this_thread::sleep_for(1s);
    return "I am test_func";
}

int test(int&& x) {
    return x;
}

int main() {
    int n = 4;
    ThreadPool threadPool(6);
    std::vector<std::future<int>> futs;
    int x = 5;

    auto test_fuc = threadPool.addTask([](){
        test(6);
    });

    auto fut = threadPool.addTask([x](){
        return test_func(x);
    });
    std::cout << fut.get() << std::endl;

    for (int i = 0; i < n; ++i) {
        futs.emplace_back(threadPool.addTask([i]() {
            std::this_thread::sleep_for(5s);
            return i;
        }));
    }
    for (int i = 0; i < n; ++i) {
        std::cout << futs[i].get() << std::endl;
    }
    return 0;
}
